<template>
	<view>
		<view class="username">
			用户名:<input type="text" v-model="uName">
		</view>
		
		<view class="password">
			密码:<input type="text" v-model="pwD">
		</view>
		<button type="primary" @click="login">登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uName:'',
				pwD:''
			}
		},
		methods: {
			login(){
				uni.request({
					url:"http://127.0.0.1:3008/api/login",
					data:{username:this.uName,password:this.pwD},
					method:'POST',
					success:function(res){
						// console.log(res)
						if(res.data.status==200){
							
							uni.switchTab({
								url:'/pages/index/index'
							})
						}else{
							uni.showToast({
								title:"登录失败"
							})
						}
					}
				})
			}
		}
	}
</script>

<style>

</style>
